/**
 * Created by ${PRODUCT_NAME}.
 * User: skyler
 * Date: 2/28/11
 * Time: 9:20 AM
 * To change this template use File | Settings | File Templates.
 */
package com.thoughtorigin.media.ui.controller {
import com.thoughtorigin.application.Disposable;
import com.thoughtorigin.media.MediaPlayer;

import com.thoughtorigin.media.MediaPlayerEvent;

import flash.events.EventDispatcher;

public class PlayPauseController extends EventDispatcher implements Disposable {

    private var _mediaPlayer: MediaPlayer;

    public function PlayPauseController(mediaPlayer: MediaPlayer) {
        init(mediaPlayer);
    }

    protected function init(mediaPlayer: MediaPlayer): void {
        _mediaPlayer = mediaPlayer;
        _mediaPlayer.addEventListener(MediaPlayerEvent.MEDIA_PLAY, onMediaPlay, false, 0, true);
        _mediaPlayer.addEventListener(MediaPlayerEvent.MEDIA_PAUSE, onMediaPause, false, 0, true);
    }

    protected function onMediaPause(event:MediaPlayerEvent):void {
        //override
    }

    protected function onMediaPlay(event:MediaPlayerEvent):void {
        //override
    }

    protected function get mediaPlayer(): MediaPlayer {
        return _mediaPlayer;
    }

    public function dispose(... args):void {
        _mediaPlayer.addEventListener(MediaPlayerEvent.MEDIA_PLAY, onMediaPlay);
        _mediaPlayer.addEventListener(MediaPlayerEvent.MEDIA_PAUSE, onMediaPause);
        _mediaPlayer = null;
    }
}
}
